package org.song.service.impl;

import org.song.mapper.TypeMapper;
import org.song.model.dto.TypeDto;
import org.song.model.vo.Type;
import org.song.service.TypeService;
import org.song.service.impl.common.AbstractBaseServiceImpl;
import org.song.util.SnowflakeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TypeServiceImpl extends AbstractBaseServiceImpl implements TypeService {

    @Autowired( required = true )
    @Qualifier( value = "typeMapper")
    private TypeMapper typeMapper;

    @Override
    public List<Type> listTypes( @NonNull TypeDto typeDto) {
        return typeMapper.listTypes(typeDto);
    }


    @Override
    public int deleteType( @NonNull Type type) {
        return typeMapper.deleteType(type);
    }

    @Override
    public int insertType( @NonNull Type type) {
        type.setId( SnowflakeUtil.getNextLongId() );
        return typeMapper.insertType(type);
    }

    @Override
    public int updateType( @NonNull Type type) {
        return typeMapper.updateType(type);
    }

}
